﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IMModel.Domain.Common;
using System.Diagnostics.Contracts;

namespace IMModel.Domain
{
    /// <summary>
    /// Контроллер расчёта индексов
    /// </summary>
    public static class CCalcControl
    {
        public static IndexContext GetDoctorsIndexContext(this Term term)
        {
            return term.GetNewIndexContext(x =>
            {
                switch (x.ObjectType)
                {
                    case IndexObjectType.Respondent:
                        var r = (Respondent)x;
                        var d = r.Person.GetDegree(term);
                        return d != null && d.IsDoctorate;
                    case IndexObjectType.Section:
                        var c = (Section)x;
                        return c.IsVospitanieNauchnihKadrov || c.IsNauchnajaDejatelnostj;
                }
                return true;
            }, DoctorAnswerVolumePolicy.Instance);
        }

        public static IndexContext GetDefaultIndexContext(this Term term)
        {
            return term.GetNewIndexContext(x => true, DefaultAnswerVolumePolicy.Instance);
        }
    }
}